chore: remove duplicate messenger files now in chat-system#167
chore: remove duplicate messenger files now in chat-system#167
Conversation
These messenger implementations are already in the chat-system crate and were not being used (mod.rs re-exports from chat-system). Removed files: - console.rs - discord.rs - google_chat.rs - imessage.rs - irc.rs - matrix.rs - slack.rs - teams.rs - telegram.rs - webhook.rs - whatsapp.rs Note: *_cli.rs files kept for now as they have RustyClaw-specific fixes that need to be backported to chat-system. Fixes #166 (partial)
Remove telegram_cli.rs, discord_cli.rs, slack_cli.rs - these were never used in the codebase. Use TelegramMessenger, DiscordMessenger, SlackMessenger from chat-system instead. MatrixCliMessenger kept temporarily because it has features not yet in chat-system's MatrixMessenger: - with_state_dir (sync token persistence) - with_allowed_chats (room filtering) - with_dm_config (DM handling) These need to be upstreamed to chat-system before MatrixCliMessenger can be removed. Removes ~24KB of dead code. Fixes #166 (continued)
chat-system 0.1.3 now includes all MatrixCliMessenger capabilities: - with_state_dir() for sync token persistence - with_allowed_chats() for room filtering - with_dm_config() for DM handling Changes: - Bump chat-system to 0.1.3 - Remove matrix_cli.rs (779 lines) - Remove matrix-cli feature flag - Update build_matrix_messenger() with new capabilities - Deprecate "matrix-cli" messenger type (use "matrix" instead) - Update all-messengers to use matrix instead of matrix-cli Completes #166
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
| // Set state directory for sync token persistence | ||
| if let Some(dirs) = directories::ProjectDirs::from("", "", "rustyclaw") { | ||
| let state_dir = dirs.data_dir().join("matrix").join(&name); | ||
| messenger = messenger.with_state_dir(state_dir); | ||
| } | ||
|
|
||
| // Set allowed chats if configured | ||
| if !config.allowed_chats.is_empty() { | ||
| messenger = messenger.with_allowed_chats(config.allowed_chats.clone()); | ||
| } | ||
|
|
||
| // Set DM config if present | ||
| if let Some(ref dm) = config.dm { | ||
| use crate::messengers::MatrixDmConfig; | ||
| let dm_config = MatrixDmConfig { | ||
| enabled: dm.enabled, | ||
| policy: dm.policy.clone().unwrap_or_else(|| "allowlist".to_string()), | ||
| allow_from: dm.allow_from.clone(), | ||
| }; | ||
| messenger = messenger.with_dm_config(dm_config); | ||
| } |
There was a problem hiding this comment.
🔴 Password-based Matrix configs bypass build_matrix_messenger, silently losing state_dir/allowed_chats/dm_config
The pre-existing generic_messenger_config function at crates/rustyclaw-core/src/gateway/messenger_handler.rs:198-215 has a "matrix" if config.access_token.is_none() arm that intercepts all password-based Matrix configs and routes them through GenericMessenger, returning early at line 84-87 before build_matrix_messenger is ever called. This means the new state_dir, allowed_chats, and dm_config setup code (lines 380-400) — migrated from the deleted MatrixCliMessenger — is only reached when access_token is set. Users migrating from matrix-cli to matrix type with password auth silently lose: (1) sync token persistence (causing re-processing of old messages on restart), (2) room allowlisting (bot responds in all rooms), and (3) DM handling configuration.
Prompt for agents
The build_matrix_messenger function (lines 349-403) adds state_dir, allowed_chats, and dm_config setup for MatrixMessenger, but this code is never reached for password-based Matrix configs. The reason is generic_messenger_config (line 198) has a match arm for "matrix" if config.access_token.is_none() that creates a GenericMessenger and returns early from create_messenger at line 84-87, bypassing build_matrix_messenger entirely.
To fix this, either:
1. Remove the "matrix" arm from generic_messenger_config (lines 198-215) so that all Matrix configs go through build_matrix_messenger, OR
2. Move the state_dir/allowed_chats/dm_config logic into the generic_messenger_config path for Matrix (though this may not be possible if GenericMessenger doesn't support those builder methods), OR
3. Add a guard condition to the generic_messenger_config "matrix" arm that also checks for allowed_chats/dm being set, falling through to build_matrix_messenger when those advanced features are configured.
Option 1 is the simplest and most correct approach given the PR's intent to consolidate matrix-cli features into the matrix type.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Fixed in 82bb28d. Removed the "matrix" if config.access_token.is_none() arm from generic_messenger_config so all Matrix configs (both access_token and password-based) now go through build_matrix_messenger, which correctly applies state_dir, allowed_chats, and dm_config.
Remove the 'matrix' arm from generic_messenger_config that intercepted password-based Matrix configs and routed them through GenericMessenger. This caused state_dir, allowed_chats, and dm_config setup to be silently skipped for password-auth Matrix users. Now all Matrix configs (both access_token and password) go through build_matrix_messenger, which already handles both auth modes and correctly applies state_dir, allowed_chats, and dm_config. Fixes Devin Review finding on PR #167. Co-Authored-By: Erica Stith <rexlunae@gmail.com>
Remove the 'matrix' arm from generic_messenger_config that intercepted password-based Matrix configs and routed them through GenericMessenger. This caused state_dir, allowed_chats, and dm_config setup to be silently skipped for password-auth Matrix users. Now all Matrix configs (both access_token and password) go through build_matrix_messenger, which already handles both auth modes and correctly applies state_dir, allowed_chats, and dm_config. Fixes Devin Review finding on PR #167. Co-Authored-By: Erica Stith <rexlunae@gmail.com>
Remove the 'matrix' arm from generic_messenger_config that intercepted password-based Matrix configs and routed them through GenericMessenger. This caused state_dir, allowed_chats, and dm_config setup to be silently skipped for password-auth Matrix users. Now all Matrix configs (both access_token and password) go through build_matrix_messenger, which already handles both auth modes and correctly applies state_dir, allowed_chats, and dm_config. Fixes Devin Review finding on PR #167. Co-Authored-By: Erica Stith <rexlunae@gmail.com>
Summary
Remove 11 duplicate messenger implementation files that are already in the
chat-systemcrate and were dead code (mod.rs re-exports from chat-system).Removed Files
Still TODO
The
*_cli.rsfiles are kept for now because they have RustyClaw-specific bug fixes that need to be backported to chat-system first:matrix_cli.rs— sync token fixes (PRs fix(matrix): Load persisted sync token on restart #130, fix(matrix): Only advance sync token when allowed rooms present #133)discord_cli.rstelegram_cli.rsslack_cli.rsAlso kept:
media.rs— media handling utilitiesstreaming.rs— stream buffer/configgroup_chat.rs— group chat configThese may be RustyClaw-specific or need evaluation for chat-system migration.
-2,202 lines deleted 🧹
Fixes #166 (partial)